Some things, if not often used, are easy to forget, such as magic methods and magic constants. Magicmethods (Magicmethods) PHP calls the methods starting with two underscores _ as magic methods, which play an important role in PHP. Magic methods
PHP Magic constant __method__ Introduction, constant __method_
__method__ is a new magic constant after PHP5, representing the name of the class grammar. The magic constant is a PHP predefined constant, its value can be changed, PHP's other
When explaining PHP constants, we know that most of the constants in PHP are unchanged, but there are eight predefined constants that will change with the location of their code, these eight constants are called magic constants. these special
This article mainly introduces the Magic method and Magic constants in PHP, has a certain reference value, now share to everyone, the need for friends can refer to
Magic method
__construct () construction method
When instantiating an object, add
There are seven magic constants in PHP, their values are actually changing, and their values change as they change position in the code. So they are called magic constants. For example, the value of __line__ depends on the row it is in the script to
Magic Method (Magic methods)PHP, which starts with two underscores __ , is called the Magic Method, which plays a pivotal role in PHP. Magic methods include:
__construct(), the constructor for the class
__destruct(), a destructor for a class
: This article mainly introduces the things you need to pay attention to when learning the _ 4_constant and the magic constant in php. if you are interested in the PHP Tutorial, please refer to it. In php, constants correspond to Variables.
PHP type conversion, constants, system constants, magic constants, constants
PHP type conversion, constants, system constants, and magic Constants
1. Automatic type conversion;
During operation and judgment, automatic type conversion is performed; 1)
This article through the PHP source code, starting from the structure of static variables, constants, magic constants analysis.
1. Static variablesAs we all know, static variables are loaded when the PHP script loads, That is 1. The object can be
In PHP, variables correspond to constants, constants are system constants, frame constants, and custom constants.
Defining constants can use the following
define("MY_FIELD",123); echo MY_FIELD;// 输出123// 如果定义常量是一个变量$name = "TEST";
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.